package java6681.group;

import java.util.ArrayList;
import java.util.List;

public class test {
    public static void main(String[] args) {
// 分组数
        int zushu = 12;

        int[] l = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84
        };

// 要随机分组的数组打乱顺序后得到的列表
        List<Integer> list = new ArrayList<Integer>();

        while (list.size() < l.length) {
            int rand = (int) (Math.random() * l.length);
            if (list.contains(l[rand])) {
                continue;
            }
            list.add(l[rand]);
        }
// 总数除以分组数得到的余数（这个要放到第一组）
        int yushu = list.size() % zushu;
// 每组成果的个数
        int geshu = (list.size() - yushu) / zushu;

// System.out.println("余树"+yushu);
// System.out.println("每个组的个数"+geshu);

// 分组后的列表（列表里装的列表）
        List<List> a = new ArrayList();

// 起始值（为了取每个分组后的组的值）
        int c = 0;
// 小组个数起始值
        int b = 1;
        for (int i = 0; i < zushu; i++) {
            List s = new ArrayList();
            for (int j = c; j < geshu * b; j++) {
                s.add(list.get(j));
                c++;
            }
            a.add(s);
            b += 1;
        }

// 把余数放到第一个组里
        int num = 0;
        if (a != null && !a.isEmpty()) {
            for (int i = 0; i < yushu; i++) {
                a.get(0).add(list.get(list.size() - (yushu - i)));
            }
        }
        for (List list1 : a) {
            num++;
            System.out.println(num + "" + list1 + "" + list1.size());
        }
    }
}
